/**
 * Classe permettant le stockage des données statistiques relatives à un ascenseur
 * @authors: Bertrand GUILLAUMOND
 * @version 1.0
 */

import java.util.*;
// Consommation électrique
// Temps de trajet
// Temps d'attente

public class Statistics{
	private int conso;
	private Vector<Integer> waitTimes = new Vector<Integer>();
	private Vector<Integer> travelTimes = new Vector<Integer>();
	private int time;
	private final int IN_MINUTES = 60;

	public void erase()
	{
		conso = 0;
		time = 0 ;
		waitTimes.clear();
		travelTimes.clear();
	}

	public void addWaitTime(int t)
	{
		waitTimes.add(t);
	}

	public void addTravelTime(int t)
	{
		travelTimes.add(t);
	}

	public float getAverageTravelTime()
	{
		int total = 0;
		if(travelTimes.size() == 0)
			return 0;
		for(int i = 0; i< travelTimes.size(); i++)
			total+=travelTimes.get(i);
		return (total / travelTimes.size()); 
	}

	public float getAverageWaitTime()
	{
		int total = 0;
		if(waitTimes.size() == 0)
			return 0;
		for(int i = 0; i< waitTimes.size(); i++)
			total+=waitTimes.get(i);
		return (total / waitTimes.size()); 
	}

	public float countCustomers()
	{
		return travelTimes.size();
	}

	
	public Statistics()
	{
		conso = 0;
	}

	public int getConso()
	{
		return conso;
	}

	public void setConso(int c)
	{
		conso = c;
	}

	public void incrementExecutionTime()
	{
		time += 5;
	}

	public int getExecutionTime()
	{
		return time;
	}

	public static String timeToWords(int time)
	{

		int j = 0; int h = 0;int m =0;
		if(time > 86400)
			j = new Double(Math.floor(time / 86400)).intValue();
			h = new Double(Math.floor((time - j*(86400)) / 3600)).intValue();
			m = new Double(Math.floor((time - j*(86400) - h*3600)/60)).intValue();

		return j+" j "+h+" h et "+m+" min";
	}
}
